package com.caigou.modules.forum.adpter

import android.text.TextUtils
import android.widget.ImageView
import com.caigou.comm.base.utils.ImageLoader
import com.caigou.modules.forum.R
import com.caigou.modules.forum.bean.PacketRecordItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/11/20
 */
class PacketDetailItemAdapter(dataset: MutableList<PacketRecordItemBean>) :
    BaseQuickAdapter<PacketRecordItemBean, BaseViewHolder>(R.layout.item_packet_detail_list, dataset), LoadMoreModule {

    override fun convert(holder: BaseViewHolder, item: PacketRecordItemBean) {
        if (TextUtils.isEmpty(item.receiverHeadImg)) {
            holder.getView<ImageView>(R.id.item_packet_detail_iv_avatar).setImageResource(R.drawable.img_comm_avatar)
        } else {
            ImageLoader.loadCircle(context, item.receiverHeadImg, holder.getView(R.id.item_packet_detail_iv_avatar))
        }

        holder.setText(R.id.item_packet_detail_tv_nickname, item.receiverNickName)
        holder.setText(R.id.item_packet_detail_tv_money, "${item.amount}元")
        holder.setText(R.id.item_packet_detail_tv_time, item.createTime)
    }
}